package com.yyge.service.impl;

import com.yyge.entity.AddrInfo;
import com.yyge.mapper.AddrInfoMapper;
import com.yyge.service.AddrInfoService;
import com.yyge.vo.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class AddrInfoServiceImpl implements AddrInfoService {
    private static Logger logger= LoggerFactory.getLogger(AddrInfoServiceImpl.class);
    private AddrInfoMapper addrInfoMapper=null;
    @Override
    public R insert(AddrInfo addrInfo) {
        // 调用数据访问层
        int insert=addrInfoMapper.insert(addrInfo);
        logger.debug("数据访问层执行新增方法完成，数据库返回受影响的行数为：" + insert);
        R r=new R();
        return insert>0?R.ok("新增成功！"):R.fail("新增失败！");
    }

    @Override
    public R deleteByPrimaryKey(Integer key) {
        int deleteByPrimaryKey=addrInfoMapper.deleteByPrimaryKey(key);
        return deleteByPrimaryKey>0?R.ok("删除成功！"):R.fail("删除失败！");
    }

    @Override
    public R updateByPrimaryKey(AddrInfo addrInfo) {
        int undate=addrInfoMapper.updateByPrimaryKey(addrInfo);
        return undate>0?R.ok("修改成功！"):R.fail("修改失败！");
    }

    @Override
    public R selectByPrimaryKey(Integer key) {
        AddrInfo addrInfo=addrInfoMapper.selectByPrimaryKey(key);
        return R.ok(addrInfo);
    }
}
